package com.beimihu.GetAFData.util.api;


import com.beimihu.GetAFData.util.HttpRequestor;
import com.google.gson.Gson;
import com.beimihu.GetAFData.data.AccessToken;

/**
 * @auther beimihu
 * @date 2024/1/29
 * @description
 */
public class WeChatApi {
    private static String corpid = "";

    private static String corpsecret = "";

    private static String url = " https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid="+corpid+"&corpsecret="+corpsecret;

    public static AccessToken getAccessToken(){
        AccessToken accessToken = new AccessToken();
        try {
            HttpRequestor httpRequestor = new HttpRequestor();
            String result = httpRequestor.sendGetRequest(url);
            System.out.println(result);
            Gson gson = new Gson();
            accessToken = gson.fromJson(result,AccessToken.class);
        }catch (Exception e){
            e.printStackTrace();
        }
        return accessToken;
    }

}
